import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.Scanner;

public class lx {

    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new FileReader(new File("text/text.txt")));
        char[][] cs = new char[30][];
        int ci = 0;
        String s;
        while ((s = br.readLine()) != null) {
            cs[ci++]= s.toCharArray();

        }
        //定义五个可行方向
        int[][] dir = {{1,0},{0,1},{1,1},{1,-1},{-1,1}};
        int cut = 0;
        //遍历矩阵中每一个位置，然后向五个方向查找
        for (int i = 0; i < cs.length; i++) {
            for (int j = 0; j < cs[i].length; j++) {
                char c = cs[i][j];
                for (int k = 0; k < 5; k++) {
                    int x = i;
                    int y = j;
                    while (true) {
                        x += dir[k][0];
                        y += dir[k][1];
                        if (x < 0 || y < 0 ||x >= cs.length || y >= cs[x].length) {
                            break;
                        }
                        if (cs[x][y] > c) {
                            cut ++;
                        }
                    }
                }
            }
        }
        System.out.println(cut);
    }
}
